// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: Precompiled Header Declarations.
//   $Id$


// stdafx.h : include file for standard system include files,
//      or project specific include files that are used frequently,
//      but are changed infrequently

#if !defined(AFX_STDAFX_H__02A0902A_F095_45F9_8E1B_AAA77C617CAF__INCLUDED_)
#define AFX_STDAFX_H__02A0902A_F095_45F9_8E1B_AAA77C617CAF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_APARTMENT_THREADED

#pragma once

#ifndef STRICT
#define STRICT
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400	// Change this to the appropriate value to target Windows 2000 or later.
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
#endif

//#define _ATL_NO_AUTOMATIC_NAMESPACE
//#define _ATL_CSTRING_NO_CRT 
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit

// turns off ATL's hiding of some common and often safely ignored warning messages
#define _ATL_ALL_WARNINGS

#include <afxwin.h>
#include <afxdisp.h>
#include <afxtempl.h>

//enable refcount tracing.
//#define _ATL_DEBUG_INTERFACES
//#include <atlstr.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#include <atlwin.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
//#define min(a,b) (a < b)?a:b
//#define max(a,b) (a > b)?a:b
#undef min
#undef max
#include <msxml6.h>

#include <COMDEF.H>
#include <windows.h>

//removal or inclusion of directed graph processing.
#define DIRECTED_GRAPH
#undef DIRECTED_GRAPH

template <class T>
inline void safeRelease(T *& p)
{
	if(p)
	{
		try
		{
			p->Release();
			p = NULL;
		}
		catch(...)
		{
			AtlTrace("failed safeRelease\n");
			ASSERT(0);
		}
	}
}

#ifdef _DEBUG
	#define SAFERELEASE(pointer,expected_refcount) safeRelease(pointer,expected_refcount)
	//<summary>
	//	calls release like safeRelease does, 
	//	but asserts if the refcount is different
	//	to the expected refcount
	//<param name="lRefCount">expected refcount</param>
	//</summary>
	template <class T>
	inline void safeRelease(T *& p,long lRefCount)
	{
		try
		{
			if(p)
			{
				long l = p->Release();
				ASSERT(l==lRefCount);
				p = NULL;
			}
		}
		catch(...)
		{
			AtlTrace("failed safeRelease\n");
			ASSERT(0);
		}
	}
#else
	#define SAFERELEASE(a,b) safeRelease(a)
#endif

template <class T>
inline void dbg_safeRelease(T *& p)
{
	try
	{
		if(p)
		{
			long l = p->Release();

			ATLTRACE("Release called, Refcount=%d\n",l);
			p = NULL;
		}
	}
	catch(...)
	{
		AtlTrace("failed safeRelease\n");
		ASSERT(0);
	}
}
#define FP_LEAN_AND_MEAN 1
//define FP_LEAN_AND_MEAN_DISABLE_SYSTRAY 1
#define FP_LEAN_AND_MEAN_SHOWSPLASH 1
#define FP_LEAN_AND_MEAN_DISABLE_CHECK_UPDATES 1
#define FP_LEAN_AND_MEAN_DISABLE_EVENT_BASED_DEBUGGING 1
#define FP_LEAN_AND_MEAN_DISABLE_OTHER_PROCESSORS_IN_VIEWLINK 1
#define FP_LEAN_AND_MEAN_REDUCE_GETIMPLEMENTATION 1

//Debugging definitions
#define DEBUG_MONITOR_REFCOUNT 1
#define DEBUG_MONITOR_DESTRUCTION 2
#define DEBUG_MONITOR_EVENTS 4
#define DEBUG_MONITOR_DATAACCESS 8
#define DEBUG_PROFILE_INITIALIZATION 16
#define DEBUG_LEVEL 0

	#if DEBUG_LEVEL & DEBUG_MONITOR_REFCOUNT
		#define safeRelease dbg_safeRelease
	#endif


//handy utilities and shortcuts.

//just shorter to write.
#define StrToBSTR _com_util::ConvertStringToBSTR
#define BSTRToStr _com_util::ConvertBSTRToString

//<summary>tests a string or string object for emptiness</summary>
//<returns>true if string is NULL, or if it points to an empty string, otherwise false</returns>
template<class T>
inline bool isEmpty(T & rString)
{
	return !rString || !rString[0];
}
//#import <DOM/DOM3XPath/DOM3XPath.dll> raw_interfaces_only, raw_native_types, named_guids, auto_search
//#import <DOM/DOM2Events/DOM2Events.dll> raw_interfaces_only, raw_native_types, named_guids, auto_search

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__02A0902A_F095_45F9_8E1B_AAA77C617CAF__INCLUDED)
